<?
 
 class Controller_Register extends Controller_Base_Admin {

 	function index($args) {
 		
 		$template = new Template ('admin/index.tmpl');
 		
 		
 		
 		$template->setArgs(
 			array(
 				tabs 		=> $this->tabs->get('register'),
 				new_users	=> $this->admin->find(array(confirmed => 0, type => 2)),
 				old_users	=> $this->admin->find(array(confirmed => 1, type => 2)),
 				menu		=> $this->menu->getHierarchicalMenu(array(uid => $this->admin->id)),
 				_user		=> $this->admin,
 				
 			)
 		);
 		
 		return array(
 			status 		=> 0,
 			template	=> $template
 		);	
 	}
 	
 	function confirm($args) {
		if($_GET[id]) {
			
			$user = $this->admin->find(array(id => $_GET[id], type => 2));
		
			$mail = new Model_Mail();

			//TODO make correct email message
			
			$text = "Для завершения регистрации перейдите по <a href='".hostname."/confirmation?action=activate&code=".$user->confirmation_id."'>ссылке</a>";

			$mail->send($user->email,'registration on www.kladeya.ru',$text);
			
			return array(status 	=> 302,	location 	=> "/admin/register/");
		}
 	}

 }
 
?>